/**
 * 学习目标： 事件传参
 *    语法：
 *      on事件类型={ () => this.handleXxx(参数) }
 *
 */

import React from 'react'
import ReactDOM from 'react-dom'

class App extends React.Component {
  state = {
    count: 0,
  }

  render() {
    return (
      <>
        <h1>Hello React</h1>
        <h2>当前的数值为{this.state.count}</h2>
        <button onClick={() => this.handleClick(-1)}>-</button>
        <span> {this.state.count} </span>
        <button onClick={() => this.handleClick(1)}>+</button>
      </>
    )
  }

  handleClick = (number) => {
    this.setState({ count: this.state.count + number })
  }
}

ReactDOM.render(<App />, document.getElementById('root'))
